import { Define, EntityObjectFactory } from 'tiny-entity2';
const EntityObjectType = EntityObjectFactory.GetEntityObjectType(process.env.dataBaseType || 'mysql');
@Define.Table({ TableName: 'storestockitem' })
export class StoreStockItem extends EntityObjectType<StoreStockItem> {
    @Define.PrimaryKey()
    id: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    storeId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    stockId: string;

    /**
     * 出入库单据id
     *
     * @type {string}
     * @memberof StoreStockItem
     */
    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        IsIndex: true
    })
    stockOrderId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    productId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
    })
    productName: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    unitName: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
    })
    type: string;

    @Define.Column({
        DataType: Define.DataType.BIGINT,
        NotAllowNULL: true,
    })
    createTime: number;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
    })
    operatorId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
    })
    operatorName: string;

    /**
     * 当前商品的库存
     *
     * @type {number}
     * @memberof StoreStockItem
     */
    @Define.Column({
        DataType: Define.DataType.Decimal,
        DataLength: 11,
        DecimalPoint: 3,
        DefaultValue: 0
    })
    stockInventoryQty: number;

    /**
     * 库存变动量
     *
     * @type {number}
     * @memberof StoreStockItem
     */
    @Define.Column({
        DataType: Define.DataType.Decimal,
        DataLength: 11,
        DecimalPoint: 3,
        DefaultValue: 0
    })
    qty: number;

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    orderId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    orderType: string;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    version: number;
}

export const StoreStockType = {
    InStock: 'inStock',
    OutStock: 'outStock',
    SoldOut: 'soldOut',
    RefundIn: 'refundIn'
}